package com.study.java.spring.reference.infrasturcture;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author lfg
 * @version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private static final String SUCCESS_CODE = "1";
    private static final String FAIL_CODE = "0";

    private String code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<>(SUCCESS_CODE, "请求成功", data);
    }

    public static <T> Result<T> fail() {
        return new Result<>(FAIL_CODE, "请求失败", null);
    }

}
